package com.jake.spring.mvc.controller;

import com.jake.spring.mvc.util.SizeUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("file")
public class FileController {

    @PostMapping("upload")
    public String upload(MultipartFile file) {
        long size = file.getSize();
        if (SizeUtils.checkUploadSize(size)) {
            return "上传成功";
        }
        return "上传文件超出1M";
    }

}
